package com.elh.lock.container;

import com.elh.lock.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *
 *
 * @author liulei
 **/
@Component
public class TheadWaitContainer {

    @Autowired
    private RedisService redisService;

    /**
     * 线程入队
     *
     * @param key
     * @param thread
     */
    public void addWaitContainer(String key,Thread thread){
        redisService.setCacheLeftObject(key,thread);
    }

    /**
     * 线程出对
     *
     * @param key
     */
    public Thread signWaitContainer(String key){
        return redisService.popCacheRightObject(key, Thread.class);
    }

}
